package com.wwz.leetcode;

public class Triangle {

    public static void main(String[] args) {
        triangle(1,5);
    }

    public static void triangle(int n, int m) {
        for (int i = 0; i < m - n; i++) {
            System.out.print(" ");
        }
        for (int j = 0; j <2*n-1 ; j++) {
            if(j%2==0) System.out.print("*");
            else System.out.print(" ");
        }
        System.out.println();
        if(n<m){
            triangle(++n,m);
        }
    }
}
